<!DOCTYPE html>
<html>
<head>
    <title>用户信息</title>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <!-- 所有的 css & js 资源 -->
    <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
    <link rel="stylesheet" href="../../static/sa.css">

    <script src="../../static/kj/vue.min.js"></script>
    <script src="../../static/kj/axios.min.js"></script>
    <script src="../../static/kj/element-ui/index.js"></script>
    <script src="../../static/kj/jquery.min.js"></script>
    <script src="../../static/kj/layer/layer.js"></script>

    <script src="../../static/sa.js"></script>
    <script src="../../sa-resources/config.js"></script>

    <style type="text/css">
        .demo-table-expand {
            font-size: 0;
        }

        .demo-table-expand label {
            width: 90px;
            color: #99a9bf;
        }

        .demo-table-expand .el-form-item {
            margin-right: 0;
            margin-bottom: 0;
            width: 100%;
            border-bottom: 1px #eeeeee solid;
        }

        .el-table .nomodify-row {
            background: #e2e2e2;
        }
    </style>
</head>
<body>
<div class="vue-box" style="display: none;" :style="'display: block;'">
    <div class="c-panel">
        <!-- ------------- 参数栏 ------------- -->
        <div class="c-title">检索参数</div>
        <el-form>
            <div class="c-item">
                <label class="c-label">昵称：</label>
                <el-input size="mini" v-model="queryParams[0].right[0]" placeholder=""></el-input>
            </div>
			
			<div class="c-item">
			    <label class="c-label">部门：</label>
			    <el-input size="mini" v-model="queryParams[1].right[0]" placeholder=""></el-input>
			</div>
			
			<div class="c-item">
			    <label class="c-label">职责：</label>
			    <el-input size="mini" v-model="queryParams[2].right[0]" placeholder=""></el-input>
			</div>
			
			<div class="c-item">
			    <label class="c-label">联系方式：</label>
			    <el-input size="mini" v-model="queryParams[3].right[0]" placeholder=""></el-input>
			</div>
			
			<div class="c-item">
			    <label class="c-label">邮箱：</label>
			    <el-input size="mini" v-model="queryParams[4].right[0]" placeholder=""></el-input>
			</div>

            <div class="c-item" style="min-width: 0px;">
                <el-button size="mini" type="primary" icon="el-icon-search" @click="params.page = 1; f5()">查询
                </el-button>
            </div>
        </el-form>

        <!-- ------------- 快捷按钮 ------------- -->
        <div class="fast-btn">
            <el-button size="mini" type="warning" icon="el-icon-download" @click="sa.exportExcel('.wuyan-table')">导出
            </el-button>
            <el-button size="mini" type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button>
        </div>

        <!-- ------------- 数据列表 ------------- -->
        <el-table :border="true" :data="dataList" size="small" ref="data-table" class="wuyan-table" row-key="id">
            <el-table-column align="center" type="selection" width="45px"></el-table-column>

            <el-table-column align="center" label="昵称" prop="nickname"></el-table-column>

            <el-table-column align="center" label="头像" prop="img">
				<template slot-scope="s">
					<img width="64" :src="s.row.img" @click="sa.showImageList([s.row.img])"/>
				</template>
			</el-table-column>

            <el-table-column align="center" label="性别" prop="sex">
				<template slot-scope="s">
					<span v-if="s.row.sex == 1">男</span>
					<span v-else>女</span>
				</template>
			</el-table-column>

            <el-table-column align="center" label="部门" prop="department"></el-table-column>

            <el-table-column align="center" label="职务职责" prop="duty"></el-table-column>

            <el-table-column align="center" label="联系方式" prop="contact"></el-table-column>

            <el-table-column align="center" label="电子邮件" prop="email"></el-table-column>

            <el-table-column align="center" label="创建时间" prop="createTime">
                <template slot-scope="s">
                    <span>{{timestampToTime(s.row.createTime)}}</span>
                </template>
            </el-table-column>

            <el-table-column align="center" label="操作" width="260px" fixed="right">
                <template slot-scope="s">
                    <el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看
                    </el-button>
					
					<el-button class="c-btn" type="primary" icon="el-icon-edit" @click="update(s.row)">修改
					</el-button>
                </template>
            </el-table-column>

        </el-table>

        <!-- ------------- 分页 ------------- -->
        <div class="page-box">
            <el-pagination background layout="total, prev, pager, next, sizes, jumper"
                           :current-page.sync="params.page" :page-size.sync="params.limit" :total="dataCount"
                           :page-sizes="[15,30,50,100,500,1000]" @current-change="f5()" @size-change="f5()">
            </el-pagination>
        </div>
    </div>
</div>

<script src="../../sa-resources/api.js"></script>
<script src="../../sa-resources/wuyan.js"></script>
<script src="../../sa-resources/element-ui-helper.js"></script>

<script>
    var app = new Vue({
        el: '.vue-box',
        data: {
            // 请求参数
            params: {
                isPage: true,
                page: 1,
                limit: 15,
                orders: '[]',
                params: '[]',
            },
            // 查询参数
            queryParams: [
				{
					left: 'nickname',
					op: 'like',
					right: ['']
				},
				{
				    left: 'department',
				    op: 'like',
				    right: ['']
				},
				{
				    left: 'duty',
				    op: 'like',
				    right: ['']
				},
				{
				    left: 'contact',
				    op: 'like',
				    right: ['']
				},
				{
				    left: 'email',
				    op: 'eq',
				    right: ['']
				},
			],
            // 排序参数
            orderParams: [],
            // 当前数据
            dataList: [],
            // 数据量
            dataCount: 0,
            // 当前选择条目-单项
            chooseData: {
                row: null,
                field: null,
            },
        },
        created: function () {
            axiosConfig(axios)
            sa.onInputEnter(); // 监听输入框的回车事件，执行查询
        },
        mounted() {
            this.f5();
        },
        methods: {
            // 刷新
            f5: function () {
                let loading = elLoadding({
                    that: this
                })

                this.params.params = queryParamsToJsonStr(this.queryParams)
                this.params.orders = JSON.stringify(this.orderParams)
                let url = getUrl('pub-user', 'list')
                let http = getHttp(axios, 'pub-user', 'list')
                http(url, {
                    params: this.params
                })
                    .then(res => {
                        this.dataList = res.list ? res.list : []; // 数据
                        this.dataCount = res.count; // 分页
                        sa.f5TableHeight(); // 刷新表格高度
                        loading.close();
                    })
                    .catch((err) => { // 请求失败处理
                        this.$notify.info({
                            title: '提示',
                            message: '初始化数据失败'
                        });

                        loading.close();
                    });
            },

            // 查看
            get: function (data) {
                sa.showIframe('查看数据', 'account-add.html?id=' + data.id + '&show=1', '600px', '500px');
            },
			
			// 修改
			update: function(data) {
				sa.showIframe('修改数据', 'user-add.html?id=' + data.id, '600px', '500px');
			},
        }
    })
</script>
</body>
</html>
